<template>
  <div class="app-container">


    <!-- 分配用户到大额贷-修改 -->
    <el-dialog
      :title="'分配用户到大额贷'"
      :visible.sync="fenpeiDialog"
      width="600px"
      append-to-body
    >
      <el-form
        ref="fenppeiData"
        :rules="fenppeiRules"
        label-width="180px"
      >

       <el-form-item label="当前选择分配的人数" prop="">
        {{this.butuiArr.length}}
        </el-form-item>

        <el-form-item label="分配的大额贷产品" prop="follow">
          <el-select
            v-model="fenppeiData.productId"
            placeholder="请选择分配的大额贷"
            style="width: 100%"
          >
            <el-option v-for="(item, index) in productListXuan" :key="index" :label="item.name" :value="item.productId" />
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="fenpeiData"
          >确 定</el-button
        >
        <el-button @click="fenpeiDialog = false">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 对话框-修改 -->
    <el-dialog
      :title="titleDialog === 'add' ? '新增用户信息' : '修改用户信息'"
      :visible.sync="openDialog"
      width="600px"
      append-to-body
    >
      <el-form
        ref="formDialog"
        :model="formDialog"
        :rules="rules"
        label-width="120px"
      >
        <el-form-item label="跟进状态" prop="follow">
          <el-select
            v-model="formDialog.follow"
            placeholder="请选择时间"
            style="width: 100%"
          >
            <el-option label="未跟进" :value="0" />
            <el-option label="已跟进" :value="1" />
          </el-select>
        </el-form-item>

        <el-form-item label="跟进时间" prop="nextTime">
          <el-date-picker
            v-model="formDialog.nextTime"
            style="width: 100%"
            type="date"
            value-format="yyyy-MM-dd 00:00:00"
            format="yyyy-MM-dd"
            placeholder="选择日期"
          />
        </el-form-item>

        <el-form-item label="跟进备注" prop="note">
          <el-input v-model="formDialog.note" placeholder="请输入" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" :loading="submitLoad" @click="submitForm"
          >确 定</el-button
        >
        <el-button @click="openDialog = false">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 对话框-分发客户 -->
    <el-dialog
      :title="'待分发客户：' + distributeNum"
      :visible.sync="distributionDialog"
      width="1000px"
      append-to-body
    >
      <div style="width: 188px; margin-bottom: 10px">
        <div class="table_border r_flex">
          <div
            v-for="(table, i) in distributionTable"
            :key="i"
            class="table_list r_transform1"
            :class="
              queryDistribution.pdStatus === table.value ? 'tableActive' : ''
            "
            @click="changdistribution(table)"
          >
            <p>{{ table.name }}</p>
          </div>
        </div>
      </div>

      <!-- 表格数据 -->
      <el-table
        v-loading="distributionLoading"
        :header-cell-style="{
          background: $store.state.app.theme.tableBack,
          color: $store.state.app.theme.tableColor,
        }"
        stripe
        border
        :data="distributionList"
        :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" width="40" />
        <!-- <el-table-column label="部门名称" align="center" prop="dept.deptName" /> -->
        <el-table-column label="业务员名称" align="center" prop="nickName" />
        <el-table-column label="现有客户数量" align="center" prop="" />
        <!-- <el-table-column label="最大拥有客户数量" align="center" prop="" /> -->
      </el-table>
      <!-- 分页 -->
      <el-row :gutter="24" class="mb8" style="margin: 20px 0px">
        <el-col
          :span="24"
          style="display: flex; justify-content: flex-end; padding: 0px"
        >
          <el-pagination
            background
            layout="prev, pager, next, sizes, total"
            :page-sizes="[10, 50, 100, 200]"
            :page-size="queryDistribution.pageSize"
            :current-page.sync="queryDistribution.pageNum"
            :total="distributionTotal"
            @current-change="DistributionPageChange"
            @size-change="
              (newSize) => {
                queryDistribution.pageSize = newSize;
                getDistributionList();
              }
            "
          />
        </el-col>
      </el-row>

      <div slot="footer" class="dialog-footer">
        <el-button
          type="primary"
          :loading="distributionLoading"
          @click="distributionSubmit"
          >确 定</el-button
        >
        <el-button @click="distributionDialog = false">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 跟进信息-详情 -->
    <el-dialog
      class="defaultDialog01"
      :title="'用户信息：'"
      :visible.sync="followDialog"
      width="1000px"
      append-to-body
    >
      <div class="follow_border">
        <el-descriptions class="margin-top" title="基本信息" :column="3" border>
          <template slot="extra">
            <!-- <el-button type="primary" size="small">操作</el-button> -->
          </template>
          <el-descriptions-item
            v-for="(followMsg, key) in followArr"
            :key="key"
          >
            <template slot="label">
              <i :class="followMsg.icon" />
              {{ followMsg.title }}
            </template>

            <div v-if="followMsg.key == 'weigh'">
              <el-rate
                v-model="followLogData[followMsg.key]"
                disabled
                :colors="['#99A9BF', '#F7BA2A', '#FF9900']"
              />
            </div>

            <div v-else-if="followMsg.key == 'follow'">
              <el-tag
                v-if="followLogData[followMsg.key] == 0"
                size="small"
                type="danger"
                >待跟进</el-tag
              >
              <el-tag v-else-if="followLogData[followMsg.key] == 1" size="small"
                >正在跟进</el-tag
              >
              <el-tag v-else-if="followLogData[followMsg.key] == 2" size="small"
                >准备办理</el-tag
              >
              <el-tag v-else-if="followLogData[followMsg.key] == 3" size="small"
                >正在办理</el-tag
              >
              <el-tag
                v-else-if="followLogData[followMsg.key] == 4"
                size="small"
                type="success"
                >放款成功</el-tag
              >
              <el-tag
                v-else-if="followLogData[followMsg.key] == 5"
                size="small"
                type="danger"
                >暂时搁置</el-tag
              >
            </div>

            <div v-else-if="followMsg.key == 'zhimaCredit'">
              <div v-if="followLogData[followMsg.key] == 0">无芝麻分</div>
              <div v-else-if="followLogData[followMsg.key] == 1">600分以下</div>
              <div v-else-if="followLogData[followMsg.key] == 2">600-650分</div>
              <div v-else-if="followLogData[followMsg.key] == 3">650-700分</div>
              <div v-else-if="followLogData[followMsg.key] == 4">700分以上</div>
            </div>

            <div v-else-if="followMsg.key == 'huabei'">
              <div v-if="followLogData[followMsg.key] == 0">无花呗</div>
              <div v-if="followLogData[followMsg.key] == 1">3000以下</div>
              <div v-else-if="followLogData[followMsg.key] == 2">
                3000-10000
              </div>
              <div v-else-if="followLogData[followMsg.key] == 3">
                10000-30000
              </div>
              <div v-else-if="followLogData[followMsg.key] == 4">30000以上</div>
            </div>

            <div v-else-if="followMsg.key == 'baitiao'">
              <div v-if="followLogData[followMsg.key] == 0">无京东白条</div>
              <div v-if="followLogData[followMsg.key] == 1">3000以下</div>
              <div v-else-if="followLogData[followMsg.key] == 2">
                3000-10000
              </div>
              <div v-else-if="followLogData[followMsg.key] == 3">
                10000-30000
              </div>
              <div v-else-if="followLogData[followMsg.key] == 4">30000以上</div>
            </div>

            <div v-else-if="followMsg.key == 'pdType'">
              <div v-if="followLogData[followMsg.key] == 1">系统派单</div>
              <div v-else-if="followLogData[followMsg.key] == 2">手动派单</div>
            </div>

            <div
              v-else-if="
                followMsg.key == 'fund' ||
                followMsg.key == 'has' ||
                followMsg.key == 'bdStatus' ||
                followMsg.key == 'houseProperty' ||
                followMsg.key == 'carProperty' ||
                followMsg.key == 'follow'
              "
            >
              <div v-if="followLogData[followMsg.key] == 0">无</div>
              <div v-else-if="followLogData[followMsg.key] == 1">有</div>
            </div>

            <div v-else-if="followMsg.key == 'phone'">
              <HiddenPhone
                v-if="followDialog"
                ref="HiddenPhone"
                :hiddenvalue="followLogData[followMsg.key]"
              />
            </div>

            <div v-else>
              {{ followLogData[followMsg.key] }}
            </div>
          </el-descriptions-item>
        </el-descriptions>

        <el-descriptions
          class="margin-top"
          title="跟进信息"
          :column="3"
          border
          style="margin-top: 20px"
        >
          <template slot="extra">
            <el-button
              type="primary"
              size="small"
              @click="followMsgShow = !followMsgShow"
            >
              {{ !followMsgShow ? "新增跟进信息" : "关闭跟进信息" }}
            </el-button>
          </template>
        </el-descriptions>

        <div class="follow_new_data">
          <el-timeline>
            <!-- 新增跟进信息 -->
            <el-timeline-item
              v-show="followMsgShow"
              timestamp="新增跟进信息"
              placement="top"
              color="#0bbd87"
            >
              <el-card>
                <el-form
                  ref="followForm"
                  :model="followForm"
                  :rules="followRules"
                  label-width="110px"
                >
                  <!-- 跟进信息 -->
                  <el-form-item label="跟进备注" prop="note">
                    <el-input
                      v-model="followForm.note"
                      type="textarea"
                      :rows="4"
                      placeholder="跟进备注"
                      maxlength="250"
                    />
                  </el-form-item>

                  <el-row :gutter="24">
                    <el-col :span="10">
                      <el-form-item
                        label="跟进状态"
                        prop="followStatus"
                        style="margin-bottom: 0px"
                      >
                        <el-select
                          v-model="followForm.followStatus"
                          placeholder="请选择状态"
                          style="width: 100%"
                        >
                          <el-option label="待跟进" :value="0" />
                          <el-option label="正在跟进" :value="1" />
                          <el-option label="准备办理" :value="2" />
                          <el-option label="正在办理" :value="3" />
                          <el-option label="放款成功" :value="4" />
                          <el-option label="暂时搁置" :value="5" />
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="11">
                      <el-form-item
                        label="下次跟进时间"
                        prop="nextTime"
                        style="margin-bottom: 0px"
                      >
                        <el-date-picker
                          v-model="followForm.nextTime"
                          style="width: 100%"
                          type="datetime"
                          value-format="yyyy-MM-dd HH:mm:ss"
                          format="yyyy-MM-dd HH:mm:ss"
                          placeholder="选择日期时间"
                        />
                      </el-form-item>
                    </el-col>

                    <el-col :span="3">
                      <el-button
                        type="primary"
                        style="width: 100%"
                        @click="addFollowMsg()"
                        >确定</el-button
                      >
                    </el-col>
                  </el-row>
                </el-form>
              </el-card>
            </el-timeline-item>
            <!-- 跟进历史 -->
            <el-timeline-item
              v-for="(followMsg, key) in followNewData"
              :key="key"
              :timestamp="followMsg.createTime"
              placement="top"
            >
              <el-card>
                <el-descriptions title="">
                  <!-- <el-descriptions-item label="用户编号">{{followMsg.id}}</el-descriptions-item> -->
                  <el-descriptions-item label="跟进状态">
                    <el-tag
                      v-if="followMsg.followStatus == 0"
                      size="small"
                      type="danger"
                      >待跟进</el-tag
                    >
                    <el-tag v-else-if="followMsg.followStatus == 1" size="small"
                      >正在跟进</el-tag
                    >
                    <el-tag v-else-if="followMsg.followStatus == 2" size="small"
                      >准备办理</el-tag
                    >
                    <el-tag v-else-if="followMsg.followStatus == 3" size="small"
                      >正在办理</el-tag
                    >
                    <el-tag
                      v-else-if="followMsg.followStatus == 4"
                      size="small"
                      type="success"
                      >放款成功</el-tag
                    >
                    <el-tag
                      v-else-if="followMsg.followStatus == 5"
                      size="small"
                      type="danger"
                      >暂时搁置</el-tag
                    >
                  </el-descriptions-item>
                  <el-descriptions-item label="跟进人员">{{
                    followMsg.userName
                  }}</el-descriptions-item>
                  <el-descriptions-item label="下次跟进时间">{{
                    followMsg.nextTime
                  }}</el-descriptions-item>
                  <el-descriptions-item label="跟进备注">{{
                    followMsg.note
                  }}</el-descriptions-item>
                </el-descriptions>
              </el-card>
            </el-timeline-item>
            <!-- 无更进历史 -->
            <p
              v-if="followNewData.length == 0"
              style="text-align: center; color: #a2a2a2; margin-bottom: 30px"
            >
              暂无跟进记录，右上角可点击新增
            </p>
          </el-timeline>
        </div>
      </div>
    </el-dialog>
    <!-- 风控信息-详情  -->
    <DialogRadarArr
      :title="'报告详情'"
      ref="DialogRadar"
      :radarData="radarData"
      :radarArr="radarArr"
    ></DialogRadarArr>
  </div>
</template>

<script>
import {
  applysUserListGk,
  delApplysUser,
  getApplysUser,
  upApplysUser,
  addApplysUser,
  exportApplysUser,
  followList,
  addfollow,
  distributeList,
  ApplysgetCustomer,
  ApplysUserList,
  getLdtz,
  userTotal,
  setDistribute
} from "@/api/business/system";
import { listProduct } from '@/api/product/product'
import { allUser, changeUserStatus, ApplysUserExport } from "@/api/system/user";
import { dataoverview } from "@/api/business/total";
import { deptCheck } from "@/api/system/dept";

import { ossUpload } from "@/api/oss/oss";
import { checkPermi } from "@/utils/permission"; // 权限判断函数
import CityInput from "@/components/CityInput";
import HiddenPhone from "@/components/HiddenPhone";
import ChannelInput from "@/components/ChannelInput";
import DialogRadarArr from "@/components/DialogRadarArr";

export default {
  name: "ProductSell",
  components: { CityInput, HiddenPhone, ChannelInput, DialogRadarArr },
  data() {
    return {
      butuiArr: [],
      productListXuan: [],
      fenpeiDialog: false,
      fenppeiData: {
        productId: ''
      },
      // 遮罩层
      loading: true,
      // 修改渠道loading
      submitLoad: false,
      distributionLoading: false,
      // 显示搜索条件
      showSearch: false,
      // 表格树数据
      businessList: [],
      distributionList: [],
      // 对话框类型
      titleDialog: "add",
      // 是否显示对话框
      openDialog: false,
      distributionDialog: false,
      // 是否显示跟进信息对话框
      followDialog: false,
      // 用户名称
      followLogName: "",
      // 用户详情数据
      followLogData: {},
      // 是否新增
      followMsgShow: false,
      // 跟进内容
      followForm: {
        // 下次跟进时间
        nextTime: "",
        // 跟进备注
        note: "",
        // 跟进状态：0待跟进 1正在跟进 2准备办理 3正在办理 4已经办理 5暂时搁置
        followStatus: "",
      },
      // 跟进记录列表
      followNewData: [],
      // 用户数据端
      followArr: [
        { title: "用户姓名", key: "name", icon: "el-icon-phone-user" },
        { title: "手机号码", key: "phone", icon: "el-icon-phone-outline" },
        { title: "客户编号", key: "id", icon: "el-icon-user" },
        { title: "创建时间", key: "createTime", icon: "el-icon-date" },
        { title: "年龄", key: "age", icon: "el-icon-user" },
        { title: "常住地", key: "city", icon: "el-icon-map-location" },
        // { title: '客户状态', key: 'follow', icon: 'el-icon-user' },
        { title: "重要程度", key: "weigh", icon: "el-icon-star-off" },
        { title: "申请金额（万）", key: "loan", icon: "el-icon-money" },
        { title: "贷款期限（月）", key: "loanTerm", icon: "el-icon-date" },
        { title: "花呗", key: "huabei", icon: "el-icon-document-checked" },
        { title: "京东白条", key: "baitiao", icon: "el-icon-document-checked" },
        {
          title: "芝麻分",
          key: "zhimaCredit",
          icon: "el-icon-document-checked",
        },
        { title: "公积金", key: "fund", icon: "el-icon-document-checked" },
        { title: "社保", key: "has", icon: "el-icon-document-checked" },
        {
          title: "保险保单",
          key: "bdStatus",
          icon: "el-icon-document-checked",
        },
        {
          title: "名下房产",
          key: "houseProperty",
          icon: "el-icon-document-checked",
        },
        {
          title: "名下车产",
          key: "carProperty",
          icon: "el-icon-document-checked",
        },
        // { title: '渠道来源', key: 'channelName', icon: 'el-icon-monitor' },
        { title: "接单人员", key: "userName", icon: "el-icon-monitor" },
        { title: "甲方渠道", key: "deptName", icon: "el-icon-monitor" },
        { title: "大额贷产品", key: "productName", icon: "el-icon-monitor" },
        { title: "跟进状态", key: "follow", icon: "el-icon-bell" },
        { title: "派单类型", key: "pdType", icon: "el-icon-bell" },
        { title: "最后跟进时间", key: "updateTime", icon: "el-icon-date" },
      ],
      // 风控
      radarData: {},
      // 风控
      radarArr: [
        [
          // { title: "用户姓名", key: "name", icon: "" },
          { title: "号码", key: "phone", icon: "" },
          { title: "年龄", key: "age", icon: "" },
          { title: "性别", key: "sex", icon: "" },
          { title: "申请准入分", key: "A22160001", icon: "" },
          { title: "申请准入置信度", key: "A22160002", icon: "" },
          { title: "申请命中机构数", key: "A22160003", icon: "" },
          { title: "申请命中消金类机构数", key: "A22160004", icon: "" },
          { title: "申请命中网络贷款类机构数", key: "A22160005", icon: "" },
          { title: "机构总查询次数", key: "A22160006", icon: "" },
          { title: "最近一次查询时间", key: "A22160007", icon: "" },
          { title: "近1个月机构总查询笔数", key: "A22160008", icon: "" },
          { title: "近3个月机构总查询笔数", key: "A22160009", icon: "" },
          { title: "近6个月机构总查询笔数", key: "A22160010", icon: "" },
          // { title: "在网时长范围起始值(单位/月)", key: "onlineTime", icon: "" },
          // {
          //   title: "归属运营商:(1-移动:2-联通:3-电信)",
          //   key: "phoneType",
          //   icon: "",
          // },
          // { title: "操作网络", key: "operator", icon: "" },
          { title: "探查结果编码", key: "result_code", icon: "" },
          // { title: '最大逾期金额', key: 'max_overdue_amt', icon: '' },
          // { title: '最长逾期天数', key: 'max_overdue_days', icon: '' },
          // { title: '最近逾期时间', key: 'max_overdue_time', icon: '' },
          { title: "当前逾期机构数", key: "currently_overdue", icon: "" },
          { title: "当前履约机构数", key: "currently_performance", icon: "" },
          { title: "异常还款机构数", key: "acc_exc", icon: "" },
          { title: "睡眠机构数", key: "acc_sleep", icon: "" },
        ],
        [
          { title: "贷款行为分", key: "B22170001", icon: "" },
          { title: "最近一次贷款放款时间", key: "B22170054", icon: "" },
          { title: "最近一次履约距今天数", key: "B22170050", icon: "" },
          { title: "正常还款订单比例", key: "B22170034", icon: "" },
          { title: "信用贷款时长", key: "B22170053", icon: "" },
          { title: "贷款已结清订单数", key: "B22170052", icon: "" },
        ],
        [
          { title: "近6个月M0+逾期贷款笔数", key: "B22170025", icon: "" },
          { title: "近6个月M1+逾期贷款笔数", key: "B22170028", icon: "" },
          { title: "近6个月累计逾期金额", key: "B22170031", icon: "" },
          { title: "近12个月M0+逾期贷款笔数", key: "B22170026", icon: "" },
          { title: "近12个月M1+逾期贷款笔数", key: "B22170029", icon: "" },
          { title: "近12个月累计逾期金额", key: "B22170032", icon: "" },
          { title: "近24个月M0+逾期贷款笔数", key: "B22170027", icon: "" },
          { title: "近24个月M1+逾期贷款笔数", key: "B22170030", icon: "" },
          { title: "近24个月累计逾期金额", key: "B22170033", icon: "" },
        ],
        [
          { title: "网贷授信额度", key: "C22180001", icon: "" },
          { title: "网贷额度置信度", key: "C22180002", icon: "" },
          { title: "网络贷款类机构数", key: "C22180003", icon: "" },
          { title: "网络贷款类产品数", key: "C22180004", icon: "" },
          { title: "网络贷款机构最大授信额度", key: "C22180005", icon: "" },
          { title: "网络贷款机构平均授信额度", key: "C22180006", icon: "" },
          { title: "消金贷款类机构数", key: "C22180007", icon: "" },
          { title: "消金贷款类产品数", key: "C22180008", icon: "" },
          { title: "消金贷款类机构最大授信额度", key: "C22180009", icon: "" },
          { title: "消金贷款类机构平均授信额度", key: "C22180010", icon: "" },
          { title: "消金建议授信额度", key: "C22180011", icon: "" },
          { title: "消金额度置信度", key: "C22180012", icon: "" },
        ],
      ],
      // 标签页筛选
      tableData: [
        { name: "全部", value: "" },
        { name: "已接单", value: 1 },
        { name: "未接单", value: 0 },
      ],
      // 标签页筛选
      distributionTable: [
        { name: "所有员工", value: "" },
        { name: "在线员工", value: 1 },
      ],
      // 是否展开，默认全部展开
      isExpandAll: true,
      // 重新渲染表格状态
      refreshTable: true,
      btLoad: false,
      // 查询参数
      queryParams: {
        pageNum: 1, // 当前页数
        pageSize: 10, // 分页大小
        age: "",
        sex: "",
        fund: "",
        bdStatus: "",
        houseProperty: "",
        has: "",
        // loanTerm: '',
        // createTime :'',
        channelName: "",
        alltime: "",
        startTime: "",
        endTime: "",
        followTime: "",
        followStartTime: "",
        followEndTime: "",
        carProperty: "",
        weigh: "",
        follow: "",
        platform: "",
        userName: "",
        jd: "",
        deptName: "",
        applyBo: {
          phone: "",
          name: "", // 渠道名
          zhimaCredit: "",
          loanTerm: "",
          isFk: "",
          pushStatus: "", // 1成功 0默认 2失败
          type: "",
          cityId: "",
          has: "",
          // loanTerm: '',
          // createTime :'',
          fund: "",
          houseProperty: "",
          carProperty: "",
          bdStatus: "",
          channelName: "",
        },
      },
      // 查询参数
      queryDistribution: {
        pageNum: 1, // 当前页数
        pageSize: 10, // 分页大小
        isHeader: 0,
        pdStatus: "",
      },
      // logo地址
      imageLogoUrl: "",
      imageLogoName: "",
      // 数据总条数
      totalPage: 0,
      distributionTotal: 0,
      // 表单参数
      value1: "",
      value2: "",
      // 新增、修改参数
      formDialog: {
        follow: "",
        note: "",
        nextTime: "",
        weigh: "",
      },
      // 分发量
      distributeNum: 0,
      // 信息统计
      userData: {
        noFollowNum: 0,
        todayNum: 0,
      },
      // 数据概括
      statisticsDta: {
        deptInfo: false,
        sysUser: false,
      },
      hkload: false,
      multipleSelection: [],
      // 新增表单校验
      rules: {
        note: [{ required: true, message: "该项不能为空", trigger: "blur" }],
        nextTime: [
          { required: true, message: "该项不能为空", trigger: "blur" },
        ],
        followStatus: [
          { required: true, message: "该项不能为空", trigger: "blur" },
        ],
      },
      fenppeiRules: {
        note: [{ required: true, message: "该项不能为空", trigger: "blur" }],
        nextTime: [
          { required: true, message: "该项不能为空", trigger: "blur" },
        ],
        followStatus: [
          { required: true, message: "该项不能为空", trigger: "blur" },
        ],
      },
      // 新增表单校验
      followRules: {
        note: [{ required: true, message: "该项不能为空", trigger: "blur" }],
        nextTime: [
          { required: true, message: "该项不能为空", trigger: "blur" },
        ],
        followStatus: [
          { required: true, message: "该项不能为空", trigger: "blur" },
        ],
      },
    };
  },
  computed: {
    // 后台配置项
    userMsg() {
      return this.$store.state.user;
    },
  },
  created(data) {
    // 初始化时间
    // this.$set(this.queryParams, 'alltime', [this.$store.state.app.theme.startTime, this.$store.state.app.theme.endTime])
    // this.$set(this.queryParams, 'startTime', this.$store.state.app.theme.startTime)
    // this.$set(this.queryParams, 'endTime', this.$store.state.app.theme.endTime)
    // 列表查询
    this.handleRadar();
  },
  methods: {
    checkPermi,
    handleRadar(row) {
      if (!this.$route.query.id) {
        this.$modal.msgSuccess("没有用户id");
        return
      }
      applysUserListGk({ id: this.$route.query.id })
        .then((res) => {
          if (res.data.code) {
            this.$message.error(res.data.msg);
          } else {
            const newData = { ...res.data.ld, ...res.data.tz, ...res.data.customer };
            console.log(newData, "newData");
            this.radarData = newData;
            this.radarData.apply_report_detail = {
              ...newData.apply_report_detail,
              ...res.data.tz,
              ...res.data.sc,
            };
            this.radarData.apply_report_detail.name = res.data.customer.name;
            this.radarData.apply_report_detail.age = res.data.customer.age;
            this.radarData.apply_report_detail.phone = res.data.customer.phone;
            this.radarData.apply_report_detail.sex = res.data.customer.sex === 0 ? "女士" : "男士";

            this.$refs.DialogRadar.visibleKey = true;
          }
          this.loading = false;
        })
        .catch((err) => {
          this.loading = false;
        });
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
      console.log(this.multipleSelection);
    },
    // 数据概括
    getdataTotal() {
      dataoverview().then((response) => {
        // this.statisticsDta = response.data
        this.$set(this, "statisticsDta", response.data);
      });
    },
    // 选择渠道
    selectChannel(data) {
      this.$set(this.queryParams.applyBo, "channelName", data.name);
    },
    // 选择渠道
    selectAChannel(data) {
      this.$set(this.queryParams.applyBo, "deptName", data.name);
    },
    async daochu() {
      const response = await ApplysUserExport(this.queryParams);
      // console.log(response, 'response')
      let blobUrl = window.URL.createObjectURL(response);
      const a = document.createElement("a");
      a.download = "大额贷申请";
      a.href = blobUrl;
      a.click();
    },
    // 修改获客开关
    statusUpList(data) {
      if (this.userMsg.userType == 2) {
        this.hkload = true;
        deptCheck({
          deptId: this.statisticsDta.deptInfo.deptId,
          zdpdStatus: data == 1 ? 0 : 1,
        })
          .then((res) => {
            this.hkload = false;
            this.statisticsDta.deptInfo.zdpdStatus = data == 1 ? 0 : 1;
            this.$message.success({
              message: "修改成功",
            });
          })
          .catch((err) => {
            this.hkload = false;
          });
      } else if (this.userMsg.userType == 3) {
        this.hkload = true;
        changeUserStatus({
          userId: this.statisticsDta.sysUser.userId,
          userName: this.statisticsDta.sysUser.userName,
          pdStatus: data == 1 ? 0 : 1,
        })
          .then((res) => {
            this.hkload = false;
            this.statisticsDta.sysUser.pdStatus = data == 1 ? 0 : 1;
            this.$message.success({
              message: "修改成功",
            });
          })
          .catch((err) => {
            this.hkload = false;
          });
      }
      this.getdataTotal();
    },
    handleSelectionChange(val) {
      this.butuiArr = val.map((res) => res.applyId);
    },
    fenpeiDiaFun() {
      if (this.butuiArr.length !== 0) {
        this.btLoad = true
        listProduct({pageNum: 1, pageSize: 999,}).then(response => {
          this.productListXuan = response.rows
          this.btLoad = false
          this.fenpeiDialog = true
          console.log(this.productListXuan, 'productListXuan')
        }).finally(() => { this.btLoad = false })

      } else {
        this.$message.error("请勾选分配数据");
      }
    },
    fenpeiData() {
      if (this.butuiArr.length !== 0) {
        setDistribute({applyIds:  this.butuiArr, productId: this.fenppeiData.productId})
          .then((res) => {
            this.fenpeiDialog = false
            this.$message.success("分配成功");
            this.butuiArr = []
            this.$refs.multipleTable.clearSelection();
          })
          .catch(() => {
          });
      } else {
        this.$message.error("请勾选分配数据");
      }
    },
    // table筛选
    changTable(table) {
      this.queryParams.jd = table.value;
      this.getList();
    },
    // table筛选
    changdistribution(table) {
      this.queryDistribution.pdStatus = table.value;
      this.getDistributionList();
    },
    // 用户信息统计
    userTotal() {
      userTotal().then((res) => {
        this.userData = res.data;
      });
    },
    // 分发数量
    distributeList() {
      distributeList().then((res) => {
        this.distributeNum = res.data.num;
      });
    },
    // 获取分发用户
    distribution() {
      this.distributionDialog = true;
      this.getDistributionList();
      // 分发数量
      this.distributeList();

      // ApplysgetCustomer().then(res => {
      //   if (this.distributeNum > 0) {
      //     this.$message.success({
      //       message: '分发成功'
      //     })
      //     // 分发数量
      //     this.distributeList()
      //     // 列表查询
      //     this.getList()
      //   } else {
      //     this.$message.error({
      //       message: '没有分发用户'
      //     })
      //   }
      // })
    },
    // 新增跟进信息
    addFollowMsg() {
      this.$refs["followForm"].validate((valid) => {
        if (valid) {
          const parm = this.followForm;
          parm.customerId = this.followLogData.applyVo.uid;
          parm.applyId = this.followLogData.applyVo.id;
          addfollow(this.followForm)
            .then((response) => {
              const newweigh = {
                id: this.followLogData.id,
                follow: this.followForm.followStatus,
              };
              upApplysUser(newweigh).then((res) => {
                this.$modal.msgSuccess("新增成功");
                this.resetForm("followForm");
                this.followList();
                this.getList();
              });
            })
            .finally(() => {});
        }
      });
    },
    // 排序类别
    sortChange(data, value) {
      this.queryParams.isAsc = data.order === "descending" ? "asc" : "desc";
      this.queryParams.orderByColumn = data.prop;
      this.getList();
    },
    // 修改权重
    changWeih(row) {
      // 点击星级修改权重
      const newweigh = {
        id: row.id,
        weigh: row.weigh,
      };
      upApplysUser(newweigh)
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("修改成功");
        })
        .catch(() => {
          this.getList();
          this.$modal.msgSuccess("修改失败");
        });
    },
    // 更新跟进列表
    followList() {
      if (!this.$route.query.id) {
        this.$modal.msgSuccess("没有用户id");
      } else {
        applysUserListGk({ id: this.$route.query.id }).then((res) => {
          this.followNewData = res.data;
          console.log(this.followNewData, 'followNewData')
        });
      }
    },
    // 时间选择
    changtime(newtime) {
      this.queryParams.startTime = newtime ? newtime[0] : "";
      this.queryParams.endTime = newtime ? newtime[1] : "";
    },

    // 时间选择
    chFollowtime(newtime) {
      this.queryParams.followStartTime = newtime ? newtime[0] : "";
      this.queryParams.followEndTime = newtime ? newtime[1] : "";
    },
    // 城市选择
    selectCity(data) {
      this.queryParams.applyBo.cityId = data.map((value) => value.ccode).join();
    },
    // 钩子
    requestUpload(param) {},
    // 上传预处理
    beforeAvatarUpload(file) {
      if (file.type.indexOf("image/") === -1) {
        this.$modal.msgError(
          "文件格式错误，请上传图片类型,如:JPG,PNG后缀的文件。"
        );
      } else {
        const reader = new FileReader();
        reader.readAsDataURL(file);
        reader.onload = () => {
          this.imageLogoUrl = reader.result;
          this.imageLogoName = file;
        };
        this.uploadImg(file);
      }
    },
    // 上传图片
    uploadImg(file) {
      const formData = new FormData();
      formData.append("file", file);
      ossUpload(formData).then((response) => {
        this.imageLogoUrl = response.data.url;
        this.$modal.msgSuccess("logo上传成功");
      });
      // let dvObj = document.createElement('input');
      // dvObj.type = 'file';
      // dvObj.id = 'inputUpLoad';
      // // 添加input
      // document.body.appendChild(dvObj);
      // // 删除input
      // document.body.removeChild(dvObj)
      // let files = document.getElementById("inputUpLoad").files //获取文件列表
      // files.value = this.imageLogoUrl;
      // let formData = new FormData();
      // formData.append("file", files[0], this.imageLogoName);
      // ossUpload(formData).then(response => {
      //   this.imageLogoUrl = response.data.imgUrl;
      //   this.$modal.msgSuccess("上传成功");
      // });
    },
    // 查询列表
    getList() {
      this.loading = true;
      this.queryParams.id = 123
      applysUserListGk(this.queryParams)
        .then((response) => {
          console.log(response, 'response')

          const newparm = response.rows.map((value) => ({
            ...value.applyVo,
            ...value,
            followStatus: value.sysFollowVos[0]
              ? value.sysFollowVos[value.sysFollowVos.length - 1].followStatus
              : "",
          }));
          this.businessList = newparm;
          this.totalPage = response.total;
          this.loading = false;
        })
        .finally(() => {
          this.loading = false;
        });
    },
    // 查询列表
    getDistributionList() {
      this.distributionLoading = true;
      allUser(this.queryDistribution)
        .then((response) => {
          // const newparm = response.rows.map(value => ({ ...value.applyVo, ...value, followStatus: value.sysFollowVos[0] ? value.sysFollowVos[0].followStatus : '' }))
          this.distributionList = response.rows;
          this.distributionTotal = response.total;
          this.distributionLoading = false;
        })
        .finally(() => {
          this.distributionLoading = false;
        });
    },
    // 分配员工
    distributionSubmit() {
      this.distributionLoading = true;
      if (this.multipleSelection.length === 0) {
        this.$message.error({
          message: "请选择分配员工",
        });
        this.distributionLoading = false;
      } else {
        const ids = this.multipleSelection.map((res) => res.userId);
        ApplysgetCustomer({ ids: ids })
          .then((res) => {
            this.$message.success({
              message: "分发成功",
            });
            // 分发数量
            this.distributeList();
            this.getList();
            this.distributionLoading = false;
          })
          .catch((err) => {
            this.distributionLoading = false;
          });
      }
    },
    // 新增按钮操作
    handleAdd() {
      if (this.formDialog.id) {
        this.formDialog = this.$options.data().formDialog;
      }
      this.openDialog = true;
      this.titleDialog = "add";
    },
    // 搜索按钮操作
    handleQuery() {
      // this.queryParams.pageNum = 1, // 当前页数
      this.getList();
      // 分发数量
      // this.distributeList();
    },
    // 重置按钮操作
    resetQuery() {
      this.resetForm("queryForm");
      this.queryParams.applyBo = {
        phone: "",
        name: "", // 渠道名
        zhimaCredit: "",
        loanTerm: "",
        pushStatus: "", // 1成功 0默认 2失败
        type: "",
        cityId: "",
        has: "",
        // loanTerm: '',
        // createTime :'',
        fund: "",
        houseProperty: "",
        carProperty: "",
        bdStatus: "",
      };

      this.handleQuery();
    },
    // 删除按钮操作
    handleDelete(row) {
      this.$modal
        .confirm('是否确认删除名称为"' + row.name + '"的数据项？')
        .then(function () {
          return delApplysUser(row.id);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    // 修改按钮操作
    handleUpdate(row) {
      this.followLogData = row;
      // 点击名字获取详情
      this.followLogName = row.name;
      this.followDialog = true;
      this.followList();

      // this.loading = true
      // const upId = row.id
      // getApplysUser(upId).then(response => {
      //   this.loading = false
      //   this.openDialog = true
      //   this.titleDialog = 'up'
      //   this.formDialog = response.data
      // }).finally(() => { this.loading = false })
    },
    // 修改按钮操作
    submitForm() {
      this.submitLoad = true;
      if (this.titleDialog === "add") {
        addApplysUser(this.formDialog)
          .then(() => {
            this.submitLoad = false;
            this.openDialog = false;
            this.getList();
            this.$modal.msgSuccess("新增成功");
          })
          .catch(() => {
            this.submitLoad = false;
          });
      } else {
        upApplysUser(this.formDialog)
          .then(() => {
            this.submitLoad = false;
            this.openDialog = false;
            this.getList();
            this.$modal.msgSuccess("修改成功");
          })
          .catch(() => {
            this.submitLoad = false;
          });
      }
    },
    // 表单重置
    reset() {
      this.form = {
        parentId: "",
        deptName: "",
        pdAmount: "",
        tag: "",
        leader: "",
        type: "",
        url: "",
        zkStatus: "1",
      };
      this.resetForm("form");
    },
    // 分页请求
    handlePageChange(data) {
      this.queryParams.pageNum = data;
      this.getList();
    },
    // 分页请求
    DistributionPageChange(data) {
      this.queryDistribution.pageNum = data;
      this.getDistributionList();
    },
    // 双击复制
    celldblclick(row, column, cell, event) {
      if (!column.property) return;
      if (!row[column.property]) return;
      const oInput = document.createElement("input");
      oInput.value = row[column.property];
      document.body.appendChild(oInput);
      oInput.select();
      document.execCommand("Copy");
      this.$message.success({
        message: "复制成功",
        showClose: true,
      });
      oInput.remove();
    },
  },
};
</script>

<style lang='scss'>
thead{
  border: 1px solid red !important;
}
.el-table--border {
  position: relative !important;
}
.yhgj .el-card__body {
  padding-bottom: 4px;
}
</style>